import React, { Component,useState } from 'react';
import PubSub from 'pubsub-js'
import Imgadd from '../../../../pages/home_lunbo/imgadd'
import { Button ,Modal} from 'antd';
import 'antd/dist/antd.css'

const App = (e) => {
    const [isModalVisible, setIsModalVisible] = useState(false);
  
    const showModal = () => {
      setIsModalVisible(true);
    };
  
    const handleOk = () => {
      e.gengxin()
      setIsModalVisible(false);
    };
  
    const handleCancel = () => {
      PubSub.publish('arguigu',{display:"none"})
      e.gengxin()
      setIsModalVisible(false);
    };
  
    return (
      <>
        <Button type="primary" onClick={showModal}>
          {e.name}
        </Button>
        <Modal width="648px" title="添加图片" visible={isModalVisible} onOk={handleOk} onCancel={handleCancel} closable footer={null}>
        <Imgadd   url="http://localhost:3001/api/lunboadd"/>
        </Modal>
      </>
    );
  };
class index extends Component {
    render() {
        const {record ,name,gengxin}=this.props
        return (
            <div>
                <App gengxin={gengxin} record={record} name={name}/>
            </div>
        );
    }
}

export default index;